#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <queue>
#include <cstdio>
#include <string>
#include <stack>
#include <set>
#define IOS ios::sync_with_stdio(false), cin.tie(0)
using namespace std;
typedef long long ll;
const ll mod=1000000007;
ll c[310][300];
ll a[310],b[310];
map<ll,ll> vis;
map<ll,bool> flag;
ll ans[310];
bool judge(ll num){
	ll k=(ll)sqrt(num*1.0);
	//k=-5;
	if(k*k==num)return true;
	return false;
}
ll quickmulti(ll x,ll y){
	ll sum=0;
	while(y){
		if(y&1){
			sum=(sum+x)%mod;
		}
		y>>=1;
		x=x*2%mod;
	}
	return sum;
}
ll quickmi(ll x,ll y){
	ll sum=1;
	while(y){
		if(y&1){
			sum=quickmulti(sum,x);
		}
		x=quickmulti(x,x);
		y>>=1;
	}
	return sum;
}
void init(){
	c[1][0]=1;
	c[1][1]=1;
	for(int i=2;i<=300;i++){
		c[i][0]=c[i][i]=1;
		for(int j=1;j<=i;j++){
			c[i][j]=(c[i-1][j]%mod+c[i-1][j-1]%mod)%mod;
		}
	}
}
int main()
{
	IOS;
	init();	
	ll t,n,num;
	ll len1,len2;
	ll Case=1;
	cin>>t;
	while(t--){
		vis.clear();
		flag.clear();
		len1=0,len2=0;
		cin>>n;
		for(ll i=1;i<=n;i++){
			cin>>num;
			vis[num]++;
			if(judge(num)&&!flag[num]){
				flag[num]=true;
				b[len2++]=num;
				continue;
			}
			if(vis[num]>1&&!flag[num]){
				flag[num]=true;
				a[len1++]=num;
			}
		}
		memset(ans,0,sizeof(ans));
		ll kk=0;
		for(int i=0;i<len1;i++){
			//cout<<a[i]<<endl;
			ll g=vis[a[i]];
			for(int k=0;k<=g;k+=2){
				ans[kk]=(ans[kk]+c[g][k])%mod;
			}
			kk++;
		}
		for(int i=0;i<len2;i++){
			//cout<<b[i]<<endl;
			ans[kk++]=quickmi(2,vis[b[i]]);
		}
		ll ANS=1;
		for(int i=0;i<len1+len2;i++){
			ANS=quickmulti(ANS,ans[i]);
		}
		ANS--;
		cout<<"Case #"<<Case++<<":"<<endl<<ANS<<endl;
	}
	getchar();
	getchar();
	return 0;
}
